import type { FunctionModel, LoginReq, LoginRes } from './types'
import { encrypt } from '@wlydfe/core'
import http from '@/service'

import { createUuid } from '@/utils/uuid'

export const login = (data: LoginReq) => {
  // 设置系统类型
  data.sysType = '31'
  const key = 'f#62($0!=4^F824.'
  data.password = encrypt(data.password, key)
  return http.post<LoginRes>(
    {
      url: '/user/login',
      data,
    },
    { urlGateway: '/gtsp-orch-platform' },
  )
}

/** 获取图片验证码 */
export const getImgCode = () => {
  const data = {
    verifyUuid: createUuid(),
    sysType: 31,
  }
  return http.post(
    {
      url: '/user/getVerificationCode',
      data,
    },
    { urlGateway: '/gtsp-orch-platform' },
  )
}

/** 获取用户菜单 */
export const getUserMenu = () => {
  return http.post<FunctionModel[]>(
    { url: '/resource/platform/31/user' },
    { urlGateway: '/gtsp-orch-platform' },
  )
}

/** 获取导出任务列表 */
export const queryExportTask = () => {
  return http.post({
    url: '/exp/exp/queryExportTask',
  })
}
